﻿<Page
    x:Name="pageRoot"
    x:Class="SmartPatientCentre.Pages.Patients"
    DataContext="{Binding DefaultViewModel, RelativeSource={RelativeSource Self}}"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:SmartPatientCentre.Pages"
    xmlns:common="using:SmartPatientCentre.Common"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d">

    <Page.Resources>
        
        <!-- Collection of items displayed by this page -->
        <CollectionViewSource
        x:Name="itemsViewSource"
        Source="{Binding Patients}"/>

    </Page.Resources>

    <!-- Top AppBar -->
    <Page.TopAppBar>
        <CommandBar>
            <AppBarButton Label="Logout" Icon="Clear" Click="LogoutButtonClick" />
            <CommandBar.SecondaryCommands>
                <AppBarButton Label="Dashboard" Icon="Home" Click="DashboardButtonClick" />
                <AppBarButton Label="My Patients" Icon="ContactInfo" Click="MyPatientsButtonClick" />
                <AppBarButton Label="All Patients" Icon="ViewAll" Click="AllPatientsButtonClick" />
            </CommandBar.SecondaryCommands>
        </CommandBar>
    </Page.TopAppBar>
    
    <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
        <Grid.ChildrenTransitions>
            <TransitionCollection>
                <EntranceThemeTransition/>
            </TransitionCollection>
        </Grid.ChildrenTransitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="140"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <!-- Horizontal scrolling grid -->
        <GridView
            x:Name="itemGridView"
            AutomationProperties.AutomationId="ItemsGridView"
            AutomationProperties.Name="Items"
            TabIndex="1"
            Grid.RowSpan="2"
            Padding="116,136,116,46"
            ItemsSource="{Binding Source={StaticResource itemsViewSource}}"
            ItemTemplate="{StaticResource PatientTile}"
            SelectionMode="None"
            IsSwipeEnabled="false" 
            IsActiveView="True" 
            IsItemClickEnabled="True" 
            ItemClick="Patient_ItemClick" />

        <!-- Back button and page title -->
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="120"/>
                <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>
            <Button x:Name="backButton" Margin="39,59,39,0" Command="{Binding NavigationHelper.GoBackCommand, ElementName=pageRoot}"
                        Style="{StaticResource NavigationBackButtonNormalStyle}"
                        VerticalAlignment="Top"
                        AutomationProperties.Name="Back"
                        AutomationProperties.AutomationId="BackButton"
                        AutomationProperties.ItemType="Navigation Button"/>
            <TextBlock x:Name="pageTitle" Style="{StaticResource HeaderTextBlockStyle}" Grid.Column="1" 
                        IsHitTestVisible="false" TextWrapping="NoWrap" VerticalAlignment="Bottom" Margin="0,0,30,40"/>
        </Grid>
        
    </Grid>
</Page>
